package com.nulldev.util.networking.npacket4.iprotocols.ncryptx;

public enum KeyExchangeMethod {
	/* nCryptX specific */

	NCRYPTX1_INSEC_RNG_KEY_GEN(10, KEMRating.VERY_BAD),
	NCRYPTX1_DHE_CURVE25519(11, KEMRating.NCRYPTX_READY),
	NCRYPTX1_SIDH_DHE(12, KEMRating.NCRYPTX_READY),
	NCRYPTX1_NEWHOPE(13, KEMRating.NCRYPTX_READY),

	/* nCrypt 2 and older methods */

	SHARED_KEY_EXCHANGE(1, KEMRating.BAD),
	PKPK_KEY_EXCHANGE(2, KEMRating.GOOD),

	;

	private final short id;
	private final KEMRating rating;

	private KeyExchangeMethod(final int f, final KEMRating rating) {
		this.id = (short) f;
		this.rating = rating;
	}

	public short id() {
		return this.id;
	}

	public KEMRating getRating() {
		return this.rating;
	}

	public static KeyExchangeMethod get(final short s) {
		for (final KeyExchangeMethod v : values())
			if (v.id == s)
				return v;
		throw new UnsupportedOperationException("Unknown method: " + s);
	}

	public static enum KEMRating {
		NCRYPTX_READY(5),
		GOOD(4),
		MEDIUM(3),
		BAD(2),
		VERY_BAD(1)

		;

		private final int rating;

		private KEMRating(final int rating) {
			this.rating = rating;
		}

		public int getIntRating() {
			return this.rating;
		}
	}
}
